﻿using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace HardcoreGame.Common.GlobalProjectiles
{
    public class SlingshootProjectile : GlobalProjectile
    {
        public override bool InstancePerEntity => true;
        public bool lavaSlingshoot;
        public bool spectreSlingshoot;
        public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone)
        {
            Player owner = Main.player[projectile.owner];
            if (lavaSlingshoot && Main.rand.NextBool(2))
            {
                target.AddBuff(BuffID.OnFire, 180);
            }
            if (spectreSlingshoot && owner.statLife < owner.statLifeMax2)
            {
                int healAmount = (int)(damageDone * 0.1f); 
                owner.statLife += healAmount;
                owner.HealEffect(healAmount); 
                for (int i = 0; i < 3; i++)
                {
                    Dust.NewDust(
                        target.position,
                        target.width,
                        target.height,
                        DustID.SpectreStaff, 
                        Scale: 1.5f
                    );
                }
            }
        }
        public override void OnHitPlayer(Projectile projectile, Player target, Player.HurtInfo info)
        {
            if (lavaSlingshoot && Main.rand.NextBool(2))
            {
                target.AddBuff(BuffID.OnFire, 180);
            }
        }
    }
}
